package org.karelun.gef.figure;

import org.eclipse.draw2d.BorderLayout;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.Shape;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.graphics.Color;

public class StateEndFigure extends NodeFigure {

	private class EndShape extends Shape {
		protected void fillShape(Graphics graphics) {
			Rectangle r = this.getBounds();
			Rectangle r1 = new Rectangle(r.x, r.y, r.width - 1, r.height - 1);
			Rectangle r2 = new Rectangle(r.x + 4, r.y + 4, r.width - 8,
					r.height - 8);
			graphics.drawOval(r1);

//			graphics.setBackgroundColor(ColorConstants.gray);
			graphics.fillOval(r2);
		}

		protected void outlineShape(Graphics graphics) {
		}
	}
	
	private EndShape shape=null;
	
	public StateEndFigure() {
		super();
		label = new Label();
		BorderLayout layout = new BorderLayout();
		setLayoutManager(layout);

		shape = new EndShape();
		shape.add(label);
		setOpaque(true);
		add(shape, BorderLayout.CENTER);

	}

	public void setBounds(Rectangle rect) {
		super.setBounds(rect);
		this.label.setBounds(rect);
	}

	@Override
	protected void setBGColor(Color color) {
		if(shape==null)
			return;
		shape.setBackgroundColor(color);
	}
}